package com.glsc.ngateway.common.base.domain.mysql.gateway.platform.it.project;

import com.glsc.ngateway.common.base.domain.mysql.BaseEntity;
import lombok.*;
import lombok.experimental.SuperBuilder;
import org.hibernate.annotations.*;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Index;
import javax.persistence.Table;


/**
 * 项目
 * @author xuchang
 */
@EqualsAndHashCode(callSuper = true)
@Data
@NoArgsConstructor
@AllArgsConstructor
@SuperBuilder
@Entity
@Where(clause = "deleted = 0")
@SQLDelete(sql = "update t_gw_it_project set deleted = UNIX_TIMESTAMP(NOW()), handled = 0 where id=?")
@SQLDeleteAll(sql = "update t_gw_it_project set deleted = UNIX_TIMESTAMP(NOW()), handled = 0 where id=?")
@Table(name = "t_gw_it_project", indexes = {@Index(name = "UK_PRO_NO", columnList = "project_no, deleted", unique = true)})
public class Project extends BaseEntity {

    private static final long serialVersionUID = 7069822598805132090L;

    @Column(name = "project_no", columnDefinition = "varchar(128) not null comment '项目编号'")
    private String projectNo;

    @Column(name = "project_name", columnDefinition = "varchar(128) not null comment '项目名称'")
    private String projectName;

    @Column(name = "project_type", columnDefinition = "varchar(32) comment '项目类型'")
    private String projectType;

    @Column(name = "implments_subject", columnDefinition = "varchar(32) comment '项目实施主体'")
    private String implmentsSubject;

    @Column(name = "importance_level", columnDefinition = "varchar(32) comment '重要程度'")
    private String importanceLevel;

    @Column(name = "project_manager", columnDefinition = "varchar(32) comment '项目经理'")
    private String projectManager;

    @Column(name = "manager_department", columnDefinition = "varchar(64) comment '经理所在部门'")
    private String managerDepartment;

    @Column(name = "contact_people", columnDefinition = "varchar(32) comment '项目对接人'")
    private String contactPeople;

    @Column(name = "contact_department", columnDefinition = "varchar(64) comment '对接人所在部门'")
    private String contactDepartment;

    /**
     * 只能是0，当通过ETL工具同步给OA后，才变为1
     */
    @Builder.Default
    @Column(name = "handled", columnDefinition = "int(2) not null default 0 comment '是否已处理：0未处理，1已处理'")
    private Integer handled = 0;
}

